package org.bangumibuddy.parser.factory;

import org.bangumibuddy.parser.AnimeMetaParser;
import org.bangumibuddy.parser.impl.RegexPatternAnimeMetaParser;
import org.bangumibuddy.parser.impl.DefaultAnimeMetaParser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class AnimeMetaParserFactory {
    static String fileNameParser = "Default";

    @Value("${config.parser.filename-parser}")
    public void setStaticValue(String fileNameParser) {
        AnimeMetaParserFactory.fileNameParser = fileNameParser;
    }

    public static AnimeMetaParser create() {
        switch (fileNameParser) {
            case "AutoBangumiParser":
                return createRegexPatternAnimeMetaParser();
            case "Default":
                return createDefaultParser();
            default:
                return createDefaultParser();
        }
    }

    public static AnimeMetaParser createRegexPatternAnimeMetaParser() {
        return new RegexPatternAnimeMetaParser();
    }

    public static AnimeMetaParser createDefaultParser() {
        return new DefaultAnimeMetaParser();
    }
}
